﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Entities;
using Context;
namespace WCF_ListenMusic.Services.Module_Category.Public
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "CategoryService" in code, svc and config file together.
    public class CategoryService : ICategoryService
    {
        Context.Connect_DBDataContext context = new Context.Connect_DBDataContext();
        public List<Category> getAllCategory()
        {
            try {
                var q = from a in context.Categories
                        select a;
                return q.ToList();
            }
            catch (Exception e)
            {
                throw new FaultException(e.Message);
            }
        }


        public List<Category> getCategory_byCountry(int countryid)
        {
            try
            {
                var q = from a in context.Categories
                        where a.CountryID.Equals(countryid)
                        select a;
                return q.ToList();
            }
            catch (Exception e)
            {
                throw new FaultException(e.Message);
            }
        }
    }
}
